package com.cat.twoPointerTechnique;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/count-number-of-homogenous-substrings/description/
 * @create 2025/8/8 18:33
 * @since JDK17
 */

public class Solution25 {
    static int MOD = ((int) (1e9 + 7));

    public int countHomogenous(String s) {
        long ans = 0;
        int n = s.length();
        for (int i = 0; i < n; ) {
            char t = s.charAt(i);
            int start = i++;
            while (i < n && s.charAt(i) == t) {
                i++;
            }
            ans = (ans + (long) (i - start) * (i - start + 1) / 2) % MOD;
        }
        return (int) ans;
    }
}
